package com.fgchen.biz;

import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * Created by Administrator on 2018-04-10.
 */
@Component
public class LifeCycleObject implements InitializingBean, DisposableBean {

    private String name;

    public LifeCycleObject() {
        System.out.println("TestObject()");
    }

    @PostConstruct
    public void init() {
        System.out.println("@PostConstruct.init()");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("InitializingBean.afterPropertiesSet()");
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("DisposableBean.destory()");
    }

    public String getName() {
        return name;
    }

    @Value("hayden")
    public void setName(String name) {
        System.out.println("setName");
        this.name = name;
    }
}
